﻿using System.Web;

namespace Sissonix.ExtRest.WADL
{
    public partial class application
    {
        private string processingClass;

        /// <remarks/>
        [System.Xml.Serialization.XmlAttributeAttribute()]
        public string ProcessingClass
        {
            get
            {
                return this.processingClass;
            }
            set
            {
                this.processingClass = value;
            }
        }

        /// <summary>
        /// Finds the first <resources> element in the WADL file
        /// that either (1) matches the current server's root host name
        /// or (2) begins with a relative path symbol (either ~ or /).
        /// </summary>
        /// <value>The current resources.</value>
        public resources CurrentResources
        {
            get
            {
                try
                {
                    HttpRequest req = HttpContext.Current.Request;
                    string host = req.ServerVariables["HTTP_HOST"];
                    resources r;
                    string ch1;
                    string resourcesBase;
                    for (int a = 0; a < resources.Length; a++)
                    {
                        r = resources[a];
                        resourcesBase = r.@base;
                        resourcesBase = resourcesBase.Replace(host, System.String.Empty);
                        ch1 = r.@base.Substring(0, 1);
                        if (ch1 == "/" || ch1 == "~")
                        {
                            return r;
                        }
                    }
                    return null;
                }
                catch (System.Exception e)
                {
                    string m = e.Message;
                    return null;
                }
            }
        }

    }
}
